// SPU模块的接口
import request from '@/utils/request.js'
import {
  HasSpuResponseData,
  HasAllTrademarResponseData,
  HasSpuImageResponseData,
  HasSpuSaleAttrResponseData,
  HasAllSaleAttrResponseData,
  AddSpuAndUpdataResponseData,
  SkuData,
  HasAddSkuResponseData,
  FindSpuIdHasSkuInfoResponseData,
  ReqNullResponseData
} from './type.js'
enum API {
  HASSpuData_URL = '/admin/product/',

  HasAllTrademarkList_URL = '/admin/product/baseTrademark/getTrademarkList',
  /* 某个SPU下的全部的收买商品的图片数据 */
  HASSpuImageList_URL = '/admin/product/spuImageList/',
  /* 获取某一个SPU下全部的已有的下销售属性接口地址 */
  HASExistingSpuSaleAttrList_URL = '/admin/product/spuSaleAttrList/',
  /* 获取整个项目全部的销售属性[颜色,版本,尺码]  */
  HasAllSaleAttrList_URL = '/admin/product/baseSaleAttrList',
  // 添加SPU
  AddSpu_URL = '/admin/product/saveSpuInfo',
  // 修改SPu
  UpDataSpu_URL = '/admin/product/updateSpuInfo',
  // 添加Sku
  AddSku_URL = '/admin/product/saveSkuInfo',
  //查看某一个已有的SPU下全部售卖的商品,

  FindSpuIdHasSkuInfo_URL = '/admin/product/findBySpuId/',
  // 删除SPU列表
  DelSpkuList_URL = '/admin/product/deleteSpu/'
}
/* h获取三级分类下的已有的SPU数据 */
export const reqHasSpuData = (page: number, limit: number, category3Id?: number | string) =>
  request.get<any, HasSpuResponseData>(
    API.HASSpuData_URL + `${page}/${limit}?category3Id=${category3Id}`
  )

export const reqHasTrademarkList = () =>
  request.get<any, HasAllTrademarResponseData>(API.HasAllTrademarkList_URL)

export const reqHasSpuImageList = (spuId: number) =>
  request.get<any, HasSpuImageResponseData>(API.HASSpuImageList_URL + `${spuId}`)

export const reqHasExistingSpuSaleAttrList = (spuId: number) =>
  request.get<any, HasSpuSaleAttrResponseData>(API.HASExistingSpuSaleAttrList_URL + `${spuId}`)

export const reqHasAllSaleAttrList = () =>
  request.get<any, HasAllSaleAttrResponseData>(API.HasAllSaleAttrList_URL)

export const reqAddSpu = (data) =>
  request.post<any, AddSpuAndUpdataResponseData>(API.AddSpu_URL, data)

export const reqUpDataSpu = (data) =>
  request.post<any, AddSpuAndUpdataResponseData>(API.UpDataSpu_URL, data)

export const reqAddSku = (data: SkuData) =>
  request.post<any, ReqNullResponseData>(API.AddSku_URL, data)

export const reqFindSpuIdHasSkuInfo = (spuid: number | string) =>
  request.get<any, FindSpuIdHasSkuInfoResponseData>(API.FindSpuIdHasSkuInfo_URL + `${spuid}`)

export const reqDelSpuList = (spuid: number | string) =>
  request.delete<any, ReqNullResponseData>(API.DelSpkuList_URL + `${spuid}`)
